﻿#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h> //include hearder file
#include <math.h>
#include <stdlib.h>
#define PI 3.1415926
void main(void)
{

	printf("My Student No is: %s, and my name is: %s \n", "20220000666", "Tinff");
	printf("Please input 3 numbers for side a, side b and angle ab of a triangle(cm)\n");
	float sidea, sideb, angleab;
	//scanf("%f %f %f",&sidea,&sideb,&angleab);
	sidea = 12;
	sideb = 25;
	angleab = 60;
	printf("The numbers inputed are: sidea = %f, sideb = %f and angleab = %f\n",
		sidea, sideb, angleab);
	float heighta;//The height correponding to side a
	float sidec;//The length of side c
	float aera, perimeter;
	heighta = sidea * sin(angleab * PI / 180); //sin accept parameter in radius
	printf("Height of side a: %f cm \n", heighta);
	aera = sideb * heighta / 2;
	printf("Aera: %f cm*cm \n", aera);
	sidec = sqrt(sidea * sidea + sideb * sideb - 2 * sidea * sideb * cos(angleab * PI / 180));
	perimeter = sidea + sideb + sidec;
	printf("perimeter: %f cm\n", perimeter);

	FILE* fp;
	fp = fopen("db.txt", "w+");
	fprintf(fp, "%f\n", perimeter);
	fclose(fp);

	fp = fopen("db.txt", "r");
	float perimeterFromFile;
	fscanf(fp, "%f", &perimeterFromFile);
	printf("perimeter: %f cm\n", perimeterFromFile);
	fclose(fp);

}